//
//  BidDetailListCell.swift
//  cxd4iphone
//
//  Created by hexy on 12/23/15.
//  Copyright © 2015 hexy. All rights reserved.
//

import UIKit

private struct kConstraints {
    
    static let margin: CGFloat = 15
    static let topViewHeight: CGFloat = xx_height(30)
    static let maxWrapWidth: CGFloat = xx_screenWidth() - 2 * kConstraints.margin
    
}

class BidDetailListCell: BaseTableViewCell {

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        self.selectionStyle = .None
    }
    override func updateUI(viewModel: BaseCellViewModel) {
        
        let vm = viewModel as! BidDetailCellViewModel
        
        describeLabel.text = vm.bidDescribeModel.value
    }
    
    override func makeUI() {
        
        self.accessoryType = .None
        
        contentView.addSubview(bottomView)
        bottomView.snp_makeConstraints { (make) -> Void in
            
            make.top.left.right.equalTo(contentView)
        }
        
        bottomView.addSubview(describeLabel)
        describeLabel.snp_makeConstraints { (make) -> Void in
            
            make.top.left.equalTo(bottomView).offset(kConstraints.margin)
            make.right.equalTo(bottomView).offset(-kConstraints.margin)
            make.bottom.equalTo(bottomView).offset(xx_height(-15))
        }
    }
    
    func rowHeight(viewModel: BidDetailCellViewModel) -> CGFloat {
        
        self.baseCellViewModel = viewModel
        
        layoutIfNeeded()
        
        return CGRectGetMaxY(bottomView.frame)
    }
    
    lazy var bottomView = UIView(bgColor: UIColor.whiteColor())
    
    
    lazy var describeLabel = UILabel(title: "", fontColor: Define.darkFontColor, bgColor: nil, fontSize: 12, maxWrapWidth: kConstraints.maxWrapWidth)
}
